package com.lj.message.controller;

import com.lj.common_web.annotation.ResponseResultVo;
import com.lj.message.service.SysMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.List;

/**
 * <p>
 * 系统消息表 前端控制器
 * </p>
 *
 * @author luojing
 * @since 2025-10-15 16:58:58
 */
@RestController
@RequestMapping("/sys/sys_message")
@ResponseResultVo
@Tag(name = "系统消息表 管理")
public class SysMessageController {

    @Resource
    private SysMessageService sysMessageService;


    @Operation(summary = "创建sse消息连接")
    @GetMapping("/open")
    @ResponseResultVo(value = false)
    public SseEmitter open(String clientId) {
        return sysMessageService.open(clientId);
    }

    @PostMapping("/delete")
    @Operation(summary = "系统消息表 删除")
    public void delete(@RequestBody List<Long> ids) {
        sysMessageService.delete(ids);
    }

    @PostMapping("/read")
    @Operation(summary = "系统消息表 已读")
    public void markRead(@RequestBody List<Long> ids) {
        sysMessageService.markRead(ids);
    }

}

